import { Blog } from "../model/Blog.js";
//定义增删改查控制器

const fn_list=async(ctx,next)=>{
    let blogs=await Blog.findAll()
    ctx.body={
        code:1000,
        msg:"查询成功",
        data:blogs,
    }


}


const fn_getByid=async(ctx,next)=>{
    ctx.body="查询指定博客"

}

const fn_add=async(ctx,next)=>{
    console.log(ctx.request.body);
    
    ctx.body="新增博客"

}

const fn_edit=async(ctx,next)=>{
    ctx.body="修改博客"

}

const fn_del=async(ctx,next)=>{
    ctx.body="删除指定博客"

}

//导出定义的方法:以数组方式存储，以对象格式导出
export default[
    {
        method:'get',
        url:'/blogs',
        fn:fn_list
    },
    {
        method:'get',
        url:'/blogs/:id',
        fn:fn_getByid
    },
    {
        method:'post',
        url:'/blogs',
        fn:fn_add
    },
    {
        method:'put',
        url:'/blogs/:id',
        fn:fn_edit
    },
    {
        method:'del',
        url:'/blogs/:id',
        fn:fn_del
    }
]
    

